<template>
    <div class="photoinfo-container">
        <h3>{{photoinfo.title}}</h3>
        <p class="subtitle">
            <span>发表时间:{{photoinfo.add_time|dateFormat}}</span>
            <span>点击：{{photoinfo.click}}次</span>
        </p>

        <hr>

        <!-- 缩略图区域 -->
         <!-- <img class="preview-img" v-for="(item,index) in list" :src="item.src" height="100" @click="$preview.open(index,list)" :key="item.src" > -->
         <vue-preview :slides="list"  @close="handleClose"></vue-preview>
       



        <!-- 图片内容区域 -->
        <div class="content" v-html="photoinfo.zhaiyao"></div>

        <!-- 评论子组件 -->
        <cmt-box :id="id"></cmt-box>
    </div>
</template>

<script>
import comment from '../subcomponents/comment.vue'
export default {
    data(){
        return{
            id:this.$route.params.id,
            photoinfo: {},
            list: [] 
        }
    },
    created(){
        this. getPhotoInfo();
        this.getThumbs();
    },
    methods:{
        getPhotoInfo(){
            this.$http.get("imageinfo/"+this.id).then(result=>{
                if(result.body.flag==true){
                    this.photoinfo=result.body.data; 
                }
            });
        },
        getThumbs(){
            this.$http.post("thumimages/search",{id:this.id}).then(result=>{
               
                    //循环每个图片数据，补全图片的宽和高
                    result.body.data.forEach(item => {
                        item.h = 800;
                        item.w = 600;
                        item.src=item.src;
                        item.msrc=item.src;
                    });
                    this.list=result.body.data;
                    console.log(this.list);
               
            });
        },
        
        handleClose () {
        console.log('close event')
      }
    },
        
    components:{
        'cmt-box':comment
    }
    
};
</script>


<style lang="scss" scoped>
.photoinfo-container{
        padding:3px;
        h3{
            color: #26A2FF;
            font-size: 15px;
            text-align: center;
            margin: 15px 0;
        }
        .subtitle{
            display: flex;
            justify-content: space-between;
        }

        .content{
            font-size: 13px;
            line-height: 30px;
        }    
        
    }
</style>

